<!DOCTYPE html>
<html>
<body>
<p>Test that Atomics.wait is not allowed on the main thread.</p>
<div id="result"></div>
<script type="text/javascript">
function log(message)
{
    document.getElementById("result").innerHTML += message + "</br>";
}

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

if (window.SharedArrayBuffer) {
    var view = new Int32Array(new SharedArrayBuffer(4));
    try {
      Atomics.wait(view, 0, 0, 0);
      log("FAIL: Calling Atomics.wait on the main thread did not throw.");
    } catch (e) {
      log("PASS: Calling Atomics.wait on the main thread throws.");
    }

    var worker = new Worker('resources/worker-atomics-wait.js');
    worker.postMessage(view);

    worker.onmessage = function(e) {
        log(e.data);
        if (e.data == 'DONE') {
            if (window.testRunner)
                testRunner.notifyDone();
        }
    };
} else {
    log("SharedArrayBuffers are not enabled -- skipping test.");
    if (window.testRunner)
        testRunner.notifyDone();
}

</script>
</body>
</html>
